package com.weipai.springboot.module.controller;

import com.weipai.springboot.model.PcNews;
import com.weipai.springboot.model.api.Response;
import com.weipai.springboot.module.service.PcNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 曹朋飞
 * @Date: 2019/01/09 13:49
 * 
 * 新闻控制类
 */
@RestController
public class PcNewsController {
    
    @Autowired
    private PcNewsService pcNewsService;

    /**
     * 分页
     * @param page
     * @param size
     * @param draw
     * @return
     */
    @RequestMapping(value = "/pcNews/list", method = RequestMethod.GET)
    public Response list(@RequestParam(value = "page") Integer page,
                         @RequestParam(value = "size") Integer size,
                         @RequestParam(value = "draw") String draw,
                         @RequestParam(value = "type", required = false) String type){
        return pcNewsService.list(page, size, draw, type);
    }

    /**
     * 获取详情
     * @param id
     * @return
     */
    @RequestMapping(value = "/pcNews/getInfoById", method = RequestMethod.GET)
    public Response getInfoById(String id){
        return pcNewsService.getInfoById(id);
    }

    /**
     * 保存--修改
     * @param pcNews
     * @return
     */
    @RequestMapping(value = "/pcNews/save", method = RequestMethod.POST)
    public Response save(PcNews pcNews){
        return pcNewsService.save(pcNews);
    }

    /**
     * 更改状态
     * @param id
     * @return
     */
    @RequestMapping(value = "/pcNews/changeStatus", method = RequestMethod.GET)
    public Response changeStatus(String id){
        return pcNewsService.changeStatus(id);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/pcNews/delete", method = RequestMethod.GET)
    public Response delete(String id){
        return pcNewsService.delete(id);
    }
    
    
    
    
    
    
}
